import { IMediaPlayCore } from "../../interfaces/IMediaPlayCore";
import { MediaPlayEvent } from "../../events/MediaPlayEvent";
//class MediaPlayCore
    
    export  class MediaPlayCore implements IMediaPlayCore
    {
        constructor(arg1: string=null, arg2: number=1000, arg3: Object=null)
        {
            
            this._url = arg1;
            this._bufferTime = arg2;
            this._callback = arg3;
            return;
        }

        public get bufferPercentage(): number
        {
            return this._bufferPercentage;
        }

        public get loadPercentage(): number
        {
            return this._loadPercentage;
        }

        public get playheadTime(): number
        {
            return this._playheadTime;
        }

        public get totalTime(): number
        {
            return this._totalTime;
        }

        public get playheadPercentage(): number
        {
            return this.totalTime != 0 ? this.playheadTime / this.totalTime : 0;
        }

        public get buffering(): Boolean
        {
            return this._buffering;
        }

        public play(): void
        {
            this._playing = true;
            var loc1;
            this._stopped = loc1 = !this._playing;
            this._paused = loc1;
            return;
        }

        public pause(): void
        {
            this._paused = true;
            var loc1;
            this._stopped = loc1 = !this._paused;
            this._playing = loc1;
            return;
        }

        public resume(): void
        {
            return;
        }

        public stop(): void
        {
            this._stopped = true;
            var loc1;
            this._paused = loc1 = !this._stopped;
            this._playing = loc1;
            return;
        }

        public seek(arg1: number=0): void
        {
            return;
        }

        public seekPercent(arg1: number=0): void
        {
            return;
        }

        public dispose(): void
        {
            if (this._callback) 
            {
                if (this._callback.hasOwnProperty("onMediaEvent")) 
                {
                    this._callback.onMediaEvent = null;
                }
                this._callback = null;
            }
            return;
        }

        protected callbackFunction(arg1: string, arg2: string=null): void
        {
            if (this._callback) 
            {
                if (this._callback.onMediaEvent) 
                {
                    this._callback.onMediaEvent(new MediaPlayEvent(arg1, this, arg2));
                }
            }
            return;
        }

        public get paused(): Boolean
        {
            return this._paused;
        }

        public get playing(): Boolean
        {
            return this._playing;
        }

        public get stopped(): Boolean
        {
            return this._stopped;
        }

        public get url(): string
        {
            return this._url;
        }

        public get mediaData(): Object
        {
            return this._mediaData;
        }

        public get volume(): number
        {
            return this._volume;
        }

        public set volume(arg1: number)
        {
            this._volume = arg1;
            return;
        }

        public get mute(): Boolean
        {
            return this._mute;
        }

        public get bufferTime(): number
        {
            return this._bufferTime;
        }

        protected /* var */_paused: Boolean=false;

        protected /* var */_playing: Boolean=false;

        protected /* var */_stopped: Boolean=true;

        protected /* var */_url: string;

        protected /* var */_mediaData: Object;

        protected /* var */_volume: number=1;

        protected /* var */_mute: Boolean=false;

        protected /* var */_bufferTime: number=1000;

        protected /* var */_buffering: Boolean=false;

        protected /* var */_bufferPercentage: number=0;

        protected /* var */_loadPercentage: number=0;

        protected /* var */_playheadTime: number=0;

        protected /* var */_totalTime: number=0;

        protected /* var */_callback: Object;
    }
